<template>
  <div :class="{'show':show}" class="header-search">
    <svg-icon class-name="search-icon" icon-class="search" @click.stop="showSrh" />
    <el-select
      ref="headerSearchSelect"
      v-model="search"
      :remote-method="querySearch"
      filterable
      default-first-option
      remote
      placeholder="Search"
      class="header-search-select"
      @change="change"
    >
      <el-option
        v-for="item in options"
        :key="item.path"
        :value="item"
        :label="item.title.join(' > ')"
      />
    </el-select>
  </div>
</template>
<script setup>
import { ref, reactive, toRefs, nextTick , onMounted} from "vue"
import store from "@/store"
const data = reactive({
  search: "",
  options: [],
  searchPool: [],
  show: false,
  fuse: undefined
})
const { search, options, searchPool, show, fuse } = toRefs(data)
const headerSearchSelect = ref(null)
const test = ref(null)
//  methods
const showSrh = async () => {
  show.value = !show.value
  if (show.value) {
    await nextTick()
    headerSearchSelect?.value?.focus()
  }
}
const change = () => {
  console.log("1")
}
const querySearch = () => {}

// const
// console.log(store.getters.permission_routes)
</script>
<style lang="scss" scoped>
.header-search {
  font-size: 0 !important;

  .search-icon {
    cursor: pointer;
    font-size: 18px;
    vertical-align: middle;
  }

  .header-search-select {
    font-size: 18px;
    transition: width 0.2s;
    width: 0;
    overflow: hidden;
    background: transparent;
    border-radius: 0;
    display: inline-block;
    vertical-align: middle;

    ::v-deep .el-input__inner {
      border-radius: 0;
      border: 0;
      padding-left: 0;
      padding-right: 0;
      box-shadow: none !important;
      border-bottom: 1px solid #d9d9d9;
      vertical-align: middle;
    }
  }

  &.show {
    .header-search-select {
      width: 210px;
      margin-left: 10px;
    }
  }
}
</style>